package components
{
	import flash.display.GradientType;
	import flash.display.Shape;
	import flash.geom.Matrix;
	
	import mx.core.UIComponent;

	public class ColoredHBar extends UIComponent
	{
		/**
		 * ColoredHBar
		 * @param width:int 
		 * @param height:int = 20 
		 * @param fill:Array = null 
		 * @param alpha:Array = null 
		 * @param spread:Array = null
		 */
		public function ColoredHBar(width:int,height:int = 20,fill:Array = null,alpha:Array = null,spread:Array = null)
		{
			var w:int = width;//Math.floor(Math.random()*width); 
			var h:int = height;
			//trace(data);
			var bar:Shape = new Shape();
			//bar.graphics.beginFill(0xFFFF00);
			//gradients
			var gradientBoxMatrix:Matrix = new Matrix();
			//this is where the gradient will go
			gradientBoxMatrix.createGradientBox(w, h, 0, 0, 0);
			//red, greed, red, green...
			//1,1,1,1...
			//0,(0+255/n),(0+255/n*2),...,255
			if(!fill)
			{
				fill = [0x000000];
			}
			if(!alpha)
			{
				alpha = [1];
			}
			if(!spread)
			{
				spread = [0];
			}
			//[0xFF0000, 0x00FF00, 0xFF0000, 0x00FF00], [1, 1, 1, 1], [0, 85, 170, 255],
			bar.graphics.beginGradientFill(GradientType.LINEAR,fill,alpha,spread,gradientBoxMatrix);
			
			bar.graphics.drawRect(0,0, w, h);
			
			bar.graphics.endFill();
			this.addChild(bar);
			super();
		}
		
	}
}